<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  Hello World
  <script>
    let messageQueue = []
    let sendMessage = message => {
      messageQueue.push(message)
      if (messageQueue.length === 1) {
        queueMicrotask(() => {
          const json = JSON.stringify(messageQueue)
          messageQueue.length = 0;
          // fetch("url-of-receiver", json)
          console.log(json)
        })
      }
    };
    queueMicrotask(() => {
      console.log('queueMicrotask')
    })
    setTimeout(() => {
      let i = 0
      while (i < 10000) {
        console.log(1000)
        i++
      }
    }, 0)
    sendMessage('刘备')
    sendMessage('关羽')
    sendMessage('曹操')
  </script>
</body>
</html>